<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 86135
  Date: 2021-12-24
  Time: 17:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品管理页面</title>
    <%@ include file="/page/menu/head.jsp" %>
    <script>
        function confirmDel(dom){
            var obj1=dom.parentNode.parentNode.children[0];
            return window.confirm("确定要删除商品"+obj1.innerText+"吗？");
            return false;
        }
    </script>
</head>
<body>
    <div id="header">
        <span class="wel_word">商品管理系统</span>

        <%-- 静态包含销售管理模块的菜单  --%>
        <%@include file="/page/menu/sale_menu.jsp"%>
    </div>
    <div id="main">
        <table>
            <tr>
                <td>名称</td>
                <td>价格</td>
                <td>销量</td>
                <td>库存</td>
                <td>图片</td>
                <td colspan="2">操作</td>
            </tr>

            <c:forEach items="${requestScope.page.items}" var="item">
                <tr>
                    <td>${item.name}</td>
                    <td>${item.price}</td>
                    <td>${item.sales}</td>
                    <td>${item.stock}</td>
                    <td><img class="item_img" src="${item.imgPath}"></td>
                    <td><a href="sale/ItemServlet?action=getItem&id=${item.id}&pageNo=${requestScope.page.pageNo}">修改</a></td>
                    <td><a onclick="return confirmDel(this)"  href="sale/ItemServlet?action=delete&id=${item.id}&pageNo=${requestScope.page.pageNo}">删除</a></td>
                </tr>
            </c:forEach>

            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td><a href="page/sale/additem.jsp?pageNo=${requestScope.page.pageTotal}">添加商品</a></td>
            </tr>
        </table>
    </div>

    <%--静态包含分页条--%>
    <%@include file="/page/menu/page_nav.jsp"%>

</body>
</html>
